﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace Just4Devs.Vsirc.Addin.UI
{
	public abstract class ScreenMessage
	{
		public static string BuildString(bool useWhitespaceBetween, params string[] parametros)
		{
			var builder = new StringBuilder();

			foreach (var parametro in parametros)
			{
				builder.Append(parametro);

				if (useWhitespaceBetween)
				{
					builder.Append(Whitespace);
				}
			}

			return builder.ToString();
		}

		public static string Whitespace
		{
			get { return " "; }
		}

		public static char WhitespaceChar
		{
			get { return ' '; }
		}

		public ScreenMessageComponent GetTimestamp()
		{
			return new ScreenMessageComponent(GetTimestampText(), Color.Blue);
		}

		protected string GetTimestampText()
		{
			return BuildString(false, "[", DateTime.Now.ToString("hh:mm:ss"), "]");
		}

		private List<ScreenMessageComponent> _parts = new List<ScreenMessageComponent>();

		public IList<ScreenMessageComponent> Parts
		{
			get { return _parts; }
		}

		protected void Add(ScreenMessageComponent part)
		{
			if (part != null)
			{
				_parts.Add(part);
			}
		}

		protected void Remove(ScreenMessageComponent part)
		{
			if (part != null)
			{
				if (_parts.Contains(part))
				{
					_parts.Remove(part);
				}
			}
		}
	}
}
